from django.conf.urls.defaults import *
from tjango.modules.models import system
system.project_name = "gestion"

from tjango.displayform.views import *
from tjango.autocomplete.views import *
from tjango.calculated.views import *
from tjango.modules.views import index,querys
from tjango.modules.models import model__action
from django.http import HttpResponseRedirect
from django.contrib import admin 
from gestion.querys.querys import look
from gestion.productos.views import etiqueta
from gestion.cuenta_corriente.views import *
from gestion.fondos.views import *
from gestion.productos.views import *
from gestion.compras.views import *
from gestion.ventas.views import *
from gestion.caja.views import *
import os.path

admin.autodiscover()


def redirect_view(request, rest_of_url):
	return HttpResponseRedirect(rest_of_url)


test = os.path.join(os.path.dirname(__file__), 'media')
admin_media = os.path.join(test, 'admin')
urlpatterns = patterns('',
    #(r'^mysite.fcgi/(?P<rest_of_url>\w+)/$', redirect_view),
  	#(r'^admin/sistema/moneda/3/$', view_page),
  	#(r'^admin/sistema/moneda/3/edit/$', edit_admin_page),
    (r'^gestion/admin/$',index),
    (r'^gestion/admin/bla/$',look),
    (r'^gestion/media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': test}),
    (r'^gestion/admin/(?P<app_label>\w+)/(?P<model_name>\w+)/(?P<rest_of_url>\d+)/edit/$', admin.site.model_page),
    #(r'^admin/(?P<app_label>\w+)/(?P<model_name>\w+)/(?P<rest_of_url>\d+)/add/$', admin.site.model_page),
    (r'^gestion/admin/(?P<app_label>\w+)/(?P<model_name>\w+)/(?P<id>\d+)/(?P<action>\w+)/$', model__action),
    (r'^gestion/admin/(?P<app_label>\w+)/(?P<model_name>\w+)/(?P<rest_of_url>\d+)/$', view_form),
    (r'^gestion/admin/querys/$',querys),
    (r'^gestion/admin/productos/etiqueta/$',etiqueta),
    (r'^gestion/admin/fondos/cheques_activos/$',Cheques_activos().view),
    (r'^gestion/admin/ventas/saldo_de_clientes/$',Saldo_de_clientes().view),
    (r'^gestion/admin/ventas/resumen_de_clientes/$',Resumen_de_clientes().view),
    (r'^gestion/admin/compras/saldo_de_proveedores/$',Saldo_de_proveedores().view),
    (r'^gestion/admin/compras/resumen_de_proveedores/$',Resumen_de_proveedores().view),
    (r'^gestion/admin/caja/resumen_de_gastos/$',Resumen_de_gastos().view),
    (r'^gestion/admin/caja/resumen_de_ingresos/$',Resumen_de_ingresos().view),
    (r'^gestion/admin/fondos/cheques_activos_print/$',Cheques_activos().printable),
    (r'^gestion/admin/ventas/saldo_de_clientes_print/$',Saldo_de_clientes().printable),
    (r'^gestion/admin/ventas/resumen_de_clientes_print/$',Resumen_de_clientes().printable),
    (r'^gestion/admin/compras/saldo_de_proveedores_print/$',Saldo_de_proveedores().printable),
    (r'^gestion/admin/compras/resumen_de_proveedores_print/$',Resumen_de_proveedores().printable),
    (r'^gestion/admin/caja/resumen_de_gastos_print/$',Resumen_de_gastos().printable),
    (r'^gestion/admin/caja/resumen_de_ingresos_print/$',Resumen_de_ingresos().printable),
    (r'^gestion/admin/productos/lista/$',lista),
    (r'^gestion/admin/productos/(?P<id>\d+)/precio/$',update_precio),
    (r'^gestion/admin/productos/(?P<id>\d+)/cantidad/$',update_cantidad),
    (r'^gestion/admin/productos/(?P<id>\d+)/producto/$',update_producto),
    
    #('admin/([^/]+)/([^/]+)/(?:(.+)/)$', model_admin_view),

    #('^r/', include('django.conf.urls.shortcut')),

    (r'^gestion/admin/(.*)', admin.site.root),
    (r'^gestion/ajax/$', ajaxer), 
    (r'^gestion/calculated/$', calculated_server), 
    (r'^gestion/autocomplete_id/(?P<cls>\w+)/(?P<id>\d+)/$', autocomplete_id), 
    (r'^gestion/autocomplete/(?P<cls>\w+)/(?P<field>\w+)/$', autocomplete), 
)

